<%@ page language="java"  pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>新增页面</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<LINK href="<%=basePath%>resource/css/admin.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="<%=basePath%>scripts/jquery-1.4.2.js"></script>
	<script type="text/javascript">
	    var basePath="<%=basePath%>";
	    function  checkadduser(){
	       String.prototype.trim=function(){
                  return this.replace(/(^\s*)|(\s*$)/g, "");
              }
             var  name=document.getElementById("name").value;
             var  userName=name.trim();
             if(userName==""){
                 alert("请填写用户名");
                 return false;
             }
             if(userName.length<2 || userName.length>10 ){
                 alert("用户名的长度应大于2 小于10");
                 return false;
             }
             var  password=document.getElementById("password").value;
             var  pass=password.trim();
             if(pass==""){
                 alert("请填写密码");
                 return false;
             }
             if(pass.length<2 || pass.length>10 ){
                 alert("密码的长度应大于2 小于10");
                 return false;
             }
             var level=document.getElementById("level").value;
             var url1 =basePath+"adminloign/addUser.shtml";
               $.ajax({
                    url: url1,
                    cache: false,
                    data: "username="+encodeURI(userName)+"&password="+pass+"&level="+level,
                    success: function(msg){
                         
                        var obj=eval('('+msg+')');
                        var result=obj[0]["message"];
                        alert(result);
                      
                 }
                });
	    }
	</script>
  </head>
  
  <body>
  <div align="center">
      <form action="">
      <table>
         <tr><td>&nbsp;用户名：</td><td><input type="text" id="name" name="name" /></td></tr>
         <tr><td>&nbsp;&nbsp; 密&nbsp;码: </td><td><input id="password" type="password" name="password"/></td></tr>
         <tr>  <td>用户级别:</td><td><select name="level">
                  <option value="0">0</option><!--对菜单具有操作权限  -->
                  <option value="1" selected="selected">1</option><!-- 具有使用权限 -->
             </select>
             </td>
          </tr>
          <tr><td colspan="2" align="center"> <input type="button" value="新增" onclick="checkadduser()"/>&nbsp;&nbsp;&nbsp;<input type="reset" value="重置"/></td></tr>
           
       </table>
      </form>
      </div>
  </body>
</html>
